package com.hujf.mapreduce.partitioner;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author Hujf
 * @title: WordCountReducer
 * @date 2021/3/3011:52
 * @description: TODO
 * KEYIN,
 * VALUEIN,
 * KEYOUT,
 * VALUEOUT
 */
public class WordCountReducer extends Reducer<Text, IntWritable, Text,IntWritable> {
    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        int sum =0;
        for(IntWritable num:values){
            sum+=num.get();
        }
        //上下文传输
        context.write(key,new IntWritable(sum));
    }
}
